package adapterPattern;


import org.junit.Test;

/**
 * @program: course
 * @author: lsn
 * @create: 2024-04-13 17:36
 * @description: 适配器模式测试类
 */
public class ApiTest {


    @Test
    public void test() {
        ThreeElectricOutlet threeElectricOutlet;  //目标接口(三相插座)
        Wash wash = new Wash(); //洗衣机
        threeElectricOutlet = wash; //洗衣机插在三相插座上
        System.out.println("使用三相插座接通电流：");
        threeElectricOutlet.connectElectricCurrnent(); //接通电流开始洗衣服

        TV tv = new TV(); //电视机
        TreeElectricAdapter adapter = new TreeElectricAdapter(tv); //把电视插在适配器上
        threeElectricOutlet = adapter;
        System.out.println("使用三相插座接通电流：");
        threeElectricOutlet.connectElectricCurrnent(); //接通电流，开始播放电视节目


    }
}

